import React, { Component } from "react";
import { connect } from 'react-redux';
import {fromJS} from 'immutable';
import { actionCreators } from '../store'
import { LoginTypeUl } from '../style';
class LoginType extends Component {
    render() {
        const { type, setType } = this.props;
        console.log(type)
        return (
            <LoginTypeUl>
                <div className={type === "psdLogin" ? "item activesd" : "item"} onClick={() => setType('psdLogin')}>密码登录</div>
                <div className={type === "codeLogin" ? "item activesd" : "item"} onClick={() => setType('codeLogin')}>验证码登录</div>
            </LoginTypeUl>
        )
    }
}
const mapStateToProps = (state, ownProps) => {
    state= fromJS(state);
    return {
        type: state.getIn(["login", 'type']),
    }
}
const mapDispatchToProps = (dispatch, ownProps) => {
    return {
        setType(val) {
            dispatch(actionCreators.changeType(val))
        },
    }
}
export default connect(mapStateToProps, mapDispatchToProps)(LoginType)